<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link
            href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css"
            rel="stylesheet"
    />
</head>
<body>
请输入华氏度：<input type="number"> <button>确认</button>
<br>
相对应摄氏度：<span></span>

</body>
<script>
    var ipt = document.querySelector('input');
    var span = document.querySelector('span');
    var btn = document.querySelector('button');
    btn.onclick = function () {
        if(iptObj.render()){
            span.innerHTML = (5 / 9 * (iptObj.render() - 32)).toFixed(3) + '℃'//保留三位小数
        } else {
            alert('请输入华氏度');
            return false
        }
    }
    var iptObj = {
        name : ipt,
        render : function () {
            var temp = this.name.value;     //获取华氏度值
            return temp
        }
    }

</script>
</html>